package com.cy2;
/*
 * 斗地主的升级版，独立完成的可还行，闪开，我要开始装逼了
 */

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

public class PokeDemo2up {
    public static void main(String[] args) {
        HashMap<Integer, String> hm = new HashMap<>();
        ArrayList<Integer> array = new ArrayList<>();
        String[] colors = {"♥", "♠", "♣", "♦"};
        String[] numbers = {"3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2"};
        int k = 0;
        for (String number : numbers) {
            for (String color : colors) {
                array.add(k);
                hm.put(k, color + number);
                k++;
            }
        }
        array.add(k);
        hm.put(k, "小王");
        k++;
        array.add(k);
        hm.put(k, "大王");

        Collections.shuffle(array);
        TreeSet<Integer> player1 = new TreeSet<>();
        TreeSet<Integer> player2 = new TreeSet<>();
        TreeSet<Integer> player3 = new TreeSet<>();
        TreeSet<Integer> dipoker = new TreeSet<>();
        for (int i = 0; i < array.size(); i++) {
            if (i >= array.size() - 3) {
                dipoker.add(array.get(i));
            } else if (i % 3 == 0) {
                player1.add(array.get(i));
            } else if (i % 3 == 1) {
                player2.add(array.get(i));

            } else {
                player3.add(array.get(i));
            }
        }
        showpokers("陈勇", player1, hm);
        showpokers("袁湘", player2, hm);
        showpokers("老婆", player3, hm);
        showpokers("底牌", dipoker, hm);
    }

    public static void showpokers(String name, TreeSet<Integer> pokers, HashMap<Integer, String> hm) {
        System.out.print(name + "的牌是：");
        for (Integer poker : pokers) {
            System.out.print(hm.get(poker) + " ");
        }
        System.out.println();
    }
}
